import { defineStore } from 'pinia'
import { IUserInfo } from '@/types/login'
import { getInfo } from '@api/user'

export const useUserStore = defineStore('userId', {
  state: (): { 
    userInfo: Partial<IUserInfo> 
  } => ({
    userInfo: {}
  }),
  
  actions: {
    async getUserInfo() {
      try {
        let res = await getInfo()
        this.userInfo = res.data?.userInfo || {}
      } catch (error) {
        console.error('获取用户信息失败:', error)
      }
    }
  }
})